import * as PIXI from 'pixi.js'
// 五行选项
const wxArr: string[] = ['gold', 'wood', 'water', 'fire', 'earth']
const origin = {
  gold: {
    x: 515,
    y: 334,
  },
  wood: {
    x: 109,
    y: 226,
  },
  water: {
    x: 241,
    y: 289,
  },
  fire: {
    x: 1344,
    y: 1286,
  },
  earth: {
    x: 1820,
    y: 1953,
  },
}

const { width, height, startX, startY } = {
  width: 82,
  height: 92,
  startX: 370,
  startY: 24,
}

export default (params: { scale: number; cbWidth: number; textureSource: PIXI.TextureSource }): PIXI.Sprite[] => {
  const wuxingSprite: PIXI.Sprite[] = [] // 五行选项
  wxArr.forEach((item: string, index: number) => {
    const { x, y } = origin[item as keyof typeof origin]
    const texture = new PIXI.Texture({
      source: params.textureSource,
      frame: new PIXI.Rectangle(x, y, width, height),
    })
    const sprite = new PIXI.Sprite(texture)
    sprite.pivot.set(0, height / 2)
    sprite.position.set(startX + index * width * 1.4, startY + height / 2)
    wuxingSprite.push(sprite)
  })
  return wuxingSprite
}
